
<div class="container">

	<form action="<?=URL?>" method="post">

		<input type="hidden" name="section" value="<?=SECTION?>">
		
		<input type="hidden" name="action" value="<?=$form?>">
		
		<input type="hidden" name="url" value="<?=URL?><?=$data['paging']['buttons']['back']['url']?>">
		
		<? foreach ($data['data'] as $item): ?>
			
			<fieldset>			

				<? foreach($data['info']['columns'] as $column): ?>
				
					<? if (!$column['hide']): ?>
					
						<div class="clearfix">
					
							<label><?=$column['alias']?></label>
							
							<div class="input">
							
								<!-- Form types -->
								
									<!-- Text -->
									
									<? if ($column['structure']['input'] == 'text'): ?>
								
										<input type="text" <? if ($column['size']): ?> maxlength="<?=$column['size']?>" <? endif; ?> name="data[<?=$column['field']?>][<?=$item[$key]?>]" value="<?=$item[$column['field']]?>">
									
									<? endif; ?>
								
									<!-- Textarea -->
									
									<? if ($column['structure']['input'] == 'textarea'): ?>
								
										<textarea <? if ($column['size']): ?> maxlength="<?=$column['size']?>" <? endif; ?> name="data[<?=$column['field']?>][<?=$item[$key]?>]"><?=$item[$column['field']]?></textarea>
									
									<? endif; ?>
								
									<!-- Select -->
									
									<? if ($column['structure']['input'] == 'select'): ?>
									
										<? if ($column['join']): ?>
										
											<select name="data[<?=$column['index']?>][<?=$item[$key]?>]">
										
												<? foreach($column['structure']['options'] as $key_opt => $val_opt): ?>
													
													<option value="<?=$key_opt?>" <? if ($item[$column['field']] == $val_opt): ?> selected <? endif; ?> ><?=$val_opt?></option>
												
												<? endforeach; ?>
										
											</select>
									
										<? else: ?>
										
											<select name="data[<?=$column['field']?>][<?=$item[$key]?>]">
											
												<? foreach($column['structure']['options'] as $key_opt => $val_opt): ?>
													
													<option <? if ($item[$column['field']] == $val_opt): ?> selected <? endif; ?> ><?=$val_opt?></option>
												
												<? endforeach; ?>
										
											</select>
									
										<? endif; ?>
										
									<? endif; ?>
									
									<!-- Calendar -->
									
									<? if ($column['structure']['input'] == 'date'): ?>
									
										<input data-ui="calendar" type="date" name="data[<?=$column['field']?>][<?=$item[$key]?>]" value="<?=$item[$column['field']]?>">
									
									<? endif; ?>
								
							</div>
							
						</div>
					
					<? endif; ?>
					
				<? endforeach; ?>
			
			</fieldset>
			
		<? endforeach; ?>
		
		<? if ($form == 'add'): ?><hr><a data-clone="fieldset:last"><?=__("Add more", "en")?></a><? endif; ?>
		
		<div class="actions">
		
			<button type="submit" class="btn primary"><?=__("Save changes", "en")?></button> <a href="<?=URL?><?=$data['paging']['buttons']['back']['url']?>" class="btn"><?=__("Cancel", "en")?></a>
		
		</div>

	</form>

</div>
